#include "InputDemo.h"
#include <QDebug>

InputDemo::InputDemo()
  : QWidget(0),
    mInputVector(4)
{
  mUI.setupUi(this);

  QMap<QString, ButtonType> buttons;
  for (unsigned int i(0); i < 10; ++i)
  {
    buttons["button "+QString::number(i)] = ButtonType(ButtonType::TYPE_KEYBOARD, Qt::Key_A+i);
  }

  QMap<QString, AxisType> axes;
  for (unsigned int i(0); i < 5; ++i)
  {
    HalfAxisType ap;
    ap.mType = HalfAxisType::TYPE_BUTTON;
    ap.mButton = ButtonType(ButtonType::TYPE_KEYBOARD, Qt::Key_0+i);
    HalfAxisType an;
    an.mType = HalfAxisType::TYPE_BUTTON;
    an.mButton = ButtonType(ButtonType::TYPE_KEYBOARD, Qt::Key_5+i);
    AxisType a;
    a.mPos = ap;
    a.mNeg = an;
    axes.insert("axis "+QString::number(i), a);
  }

  mInputVector[0] = new InputMapping(buttons, axes);
  mInputVector[1] = new InputMapping(buttons, axes);
  mInputVector[2] = new InputMapping(buttons, axes);
  mInputVector[3] = new InputMapping(buttons, axes);

  connect(mUI.button, SIGNAL(clicked()), this, SLOT(buttonClick()));
}

void InputDemo::buttonClick()
{
  mInputVector = InputMappingDialog::remapInputs(mInputVector);
}
